import {ViewerNameType} from "yt-cesium";

export const enum RunStepFn {
  firstStep = 'firstStep',
  secondStep = 'secondStep',
  thirdStep = 'thirdStep'
}

type SynchronizeDataType<T> = {
  simTimeField: keyof T
}

type SynchronizeReturnType<T> = {
  run: (data: T) => void
}

export function synchronizeTime<T extends object>(config?: SynchronizeDataType<T>): SynchronizeReturnType<T>
export function synchronizeTime<T extends object>(config?: SynchronizeDataType<T>, viewerName?: ViewerNameType): SynchronizeReturnType<T>

export function synchronizeTime<T extends object>(config?: SynchronizeDataType<T>, viewerName?: ViewerNameType) {
  const {simTimeField = 'simTime'} = config ?? {};

  const currentStep: RunStepFn = RunStepFn.firstStep;
  const cacheArray = [];

  const firstStepFn = (data: T) => {
  }

  const secondStepFn = (data: T) => {

  }
  const runStepMethod = {
    [RunStepFn.firstStep]: firstStepFn,
    [RunStepFn.secondStep]: (data: T) => {
    },
    [RunStepFn.thirdStep]: (data: T) => {
    }
  }

  return {
    run: runStepMethod[currentStep]
  }
}

interface TimeDataOpt {
  simTime: number
  speed: number
}

const {run} = synchronizeTime<TimeDataOpt>()

run({simTime: 1212, speed: 1212})